package com.bootdo.system.service.impl;

import com.bootdo.system.dao.ProjectDao;
import com.bootdo.system.dao.UserDao;
import com.bootdo.system.domain.ProjectDO;
import com.bootdo.system.domain.UserDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.bootdo.system.dao.UserInnerDao;
import com.bootdo.system.domain.UserInnerDO;
import com.bootdo.system.service.UserInnerService;



@Service
public class UserInnerServiceImpl implements UserInnerService {
	@Autowired
	private UserInnerDao userInnerDao;
	@Autowired
	private UserDao userDao;
	@Autowired
	private ProjectDao projectDao;
	
	@Override
	public UserInnerDO get(Integer id){
        UserInnerDO userInnerDO = userInnerDao.get(id);
        UserDO userDO = userDao.get(userInnerDO.getUserId());
        userInnerDO.setUserDO(userDO);

        ProjectDO projectDO = projectDao.get(userInnerDO.getProjectId());
        userInnerDO.setProjectDO(projectDO);
        return userInnerDO;
	}
	
	@Override
	public List<UserInnerDO> list(Map<String, Object> map){
        List<UserInnerDO> list = userInnerDao.list(map);
        for (UserInnerDO userInnerDO : list) {
            UserDO userDO = userDao.get(userInnerDO.getUserId());
            userInnerDO.setUserDO(userDO);

            ProjectDO projectDO = projectDao.get(userInnerDO.getProjectId());
            userInnerDO.setProjectDO(projectDO);
        }
        return list;
	}
	
	@Override
	public int count(Map<String, Object> map){
		return userInnerDao.count(map);
	}
	
	@Override
	public int save(UserInnerDO userInner){
		return userInnerDao.save(userInner);
	}
	
	@Override
	public int update(UserInnerDO userInner){
		return userInnerDao.update(userInner);
	}
	
	@Override
	public int remove(Integer id){
		return userInnerDao.remove(id);
	}
	
	@Override
	public int batchRemove(Integer[] ids){
		return userInnerDao.batchRemove(ids);
	}

	@Override
	public UserInnerDO getUserInnerByUserIdAndProjectId(Long userId, Integer projectId) {
		return userInnerDao.getUserInnerByUserIdAndProjectId(userId,projectId);
	}

}
